<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class RoleRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $id=$this->route('role');
//        dd($id);
        return [
                'cname'=>'required|unique:roles,cname,'.$id['id'],
                'name'=>'required|unique:roles,cname,'.$id['id'],
        ];
    }
    public function messages()
    {
        return [
                'cname.required'=>'角色的中文名称不能为空',
                'name.required'=>'角色的英文名称不能为空',
                'name.unique'=>'角色的英文名称不能重复',
                'cname.unique'=>'角色的中文名称不能重复'
        ];
    }
}
